package com.itheima.app.controller;

import com.itheima.app.usermanager.SettingManager;
import com.itheima.domain.db.Notification;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class SettingController {

    @Autowired
    private SettingManager settingManager;


    // 查询通用设置
    @GetMapping("/users/settings")
    public ResponseEntity findSettingVo(){
        // 调用manager
        return settingManager.findSettingVo();
    }
    //添加黑名单问题
    @PostMapping("/users/questions")
    public void savaquestion(@RequestBody Map<String,String> param){
        String content = param.get("content");
        settingManager.sava(content);
    }
    //推送消息添加
    @PostMapping("/users/notifications/setting")
    public void  save( @RequestBody Notification param){
        settingManager.save(param);
    }
    //黑名单查询
    @GetMapping("/users/blacklist")
    public ResponseEntity blackfindByPage(@RequestParam(value = "page", defaultValue = "1") Integer pageNum,
                                          @RequestParam(value = "pagesize", defaultValue = "10") Integer pageSize){
       return settingManager.blackfindByPage(pageNum,pageSize);
    }
    //黑名单移除
    @DeleteMapping("/users/blacklist/{uid}")
    public void deleteblack(@PathVariable Integer uid){
        settingManager.delete(uid);
    }
    }